package net.cooltain.warhammer.running.entity;

import java.util.List;
import java.util.HashSet;
import java.util.Set;

import net.cooltain.warhammer.framework.entity.CardEntity;

/**
 * 游戏运行中卡牌的状态
 * @author cooltain
 */
public class MotionCard {
	
	public Integer uniqueKey ;
	
	public MotionPlayerZone player;
	// 卡牌的原始属性
	public CardEntity cardEntity;
	
	//当前的数据,不包含当前回合有效的数据
	private int costCurrent  = 0; //2 当前费用
	private int loyalCurrent = 0; //4 当前忠诚图示
	private int powerCurrent = 0; //5 当前能力图示
	private int healthCurrent= 0; //7当前生命值
	
	//仅限当前回合有效,回合结束即消失
	private int costRound  = 0; //2 当前费用
	private int loyalRound = 0; //4 当前忠诚图示
	private int powerRound = 0; //5 当前能力图示
	private int healthRound= 0; //7当前生命值
	
	private int damageCount= 0; //已受到的伤害
	
	private int damageUnCaculate= 0; //已分配,未执行的伤害

	
	/** 拥有可视权限的用户 */
	private Set<MotionPlayerZone> visiblePlayers ;
	
	/** 是否腐化,true腐化 */
	private boolean isCorrupt ;
	
	/** 是否背面朝上,true背面朝上,false正面朝上 */
	private boolean isFlip ;
	
	/** 是否设施卡,true是,false不是 */
	private boolean isDevelopment ;
	
	/** 是否附加卡,true是,false不是 */
	private boolean isAttachment = false;
	
	/** 被这张卡附加的卡片,true是,false不是 */
	private MotionCard attachmentTo ;
	
	/** 本卡是否有附加卡,true是,false不是 */
	private boolean hasAttachment = false;
	
	/** 拥有的附加卡列表,true是,false不是 */
	private List<MotionCard> attachmentList ;
	
	/** 这张卡正在执行的任务 null表示没执行*/
	private MotionCard forQuestCard;
	
	/** 
	 * 如果这张卡是任务卡时，这个属性才有效<br>
	 * 这张任务卡上正在执行任务的单位卡 null表示无单位*/
	private MotionCard questUnitCard;
	
	/** 所处区域<br>
	 * PlayZoneConstant.xxx */
	public Integer currentZone ; 

	// Get & Set Method ========================================================
	public int getCostSum() {
		return costCurrent+costRound;
	}
	public int getCostCurrent() {
		return costCurrent;
	}
	public void setCostCurrent(int costCurrent) {
		this.costCurrent = costCurrent;
	}
	public int getCostRound() {
		return costRound;
	}
	public void setCostRound(int costRound) {
		this.costRound = costRound;
	}
	
	
	public int getLoyalSum() {
		return loyalCurrent+loyalRound;
	}
	public int getLoyalCurrent() {
		return loyalCurrent;
	}
	public void setLoyalCurrent(int loyalCurrent) {
		this.loyalCurrent = loyalCurrent;
	}
	public int getLoyalRound() {
		return loyalRound;
	}
	public void setLoyalRound(int loyalRound) {
		this.loyalRound = loyalRound;
	}

	public int getPowerSum(){
		return powerCurrent + powerRound;
	}
	public int getPowerCurrent() {
		return powerCurrent;
	}
	public void setPowerCurrent(int powerCurrent) {
		this.powerCurrent = powerCurrent;
	}
	public int getPowerRound() {
		return powerRound;
	}
	public void setPowerRound(int powerRound) {
		this.powerRound = powerRound;
	}
	
	
	/**
	 * 伤害标识物
	 * @return
	 */
	public int getDamageCount() {
		return damageCount;
	}
	
	/**
	 * 当前生命值+本回合加成-本回合扣除-已受到的伤害
	 * @return
	 */
	public int getHealthSum() {
		return healthCurrent+healthRound - damageCount;
	}
	public int getHealthMax() {
		return healthCurrent+healthRound ;
	}
	public int getHealthCurrent() {
		return healthCurrent;
	}
	public void setHealthCurrent(int healthCurrent) {
		this.healthCurrent = healthCurrent;
	}
	public int getHealthRound() {
		return healthRound;
	}
	public void setHealthRound(int healthRound) {
		this.healthRound = healthRound;
	}
	
	
	
	public boolean isCorrupt() {
		return isCorrupt;
	}
	public void setCorrupt(boolean isCorrupt) {
		this.isCorrupt = isCorrupt;
	}
	/** 是否背面朝上,true背面朝上,false正面朝上 */
	public boolean isFlip() {
		return isFlip;
	}
	public void setFlip(boolean isFlip) {
		this.isFlip = isFlip;
	}
	public boolean isDevelopment() {
		return isDevelopment;
	}
	public void setDevelopment(boolean isDevelopment) {
		this.isDevelopment = isDevelopment;
	}
	
	public boolean isAttachment() {
		return isAttachment;
	}
	public void setAttachment(boolean isAttachment) {
		this.isAttachment = isAttachment;
	}
	public MotionCard getAttachmentTo() {
		return attachmentTo;
	}
	public void setAttachmentTo(MotionCard attachmentTo) {
		this.attachmentTo = attachmentTo;
	}
	
	public boolean isHasAttachment() {
		return hasAttachment;
	}
	public void setHasAttachment(boolean hasAttachment) {
		this.hasAttachment = hasAttachment;
	}
	public List<MotionCard> getAttachmentList() {
		return attachmentList;
	}
	public void setAttachmentList(List<MotionCard> attachmentList) {
		this.attachmentList = attachmentList;
	}
	
	public MotionCard getForQuestCard() {
		return forQuestCard;
	}
	public void setForQuestCard(MotionCard forQuestCard) {
		this.forQuestCard = forQuestCard;
	}
	public MotionCard getQuestUnitCard() {
		return questUnitCard;
	}
	public void setQuestUnitCard(MotionCard questUnitCard) {
		this.questUnitCard = questUnitCard;
	}
	
	public Set<MotionPlayerZone> getVisiblePlayers() {
		return visiblePlayers;
	}
	public void setVisiblePlayers(Set<MotionPlayerZone> visiblePlayers) {
		this.visiblePlayers = visiblePlayers;
	}
	
	// =========================================================================
	
	/**
	 * 增加可视权限
	 * @param player
	 */
	public void addVisiblePlayer(MotionPlayerZone player){
		if(visiblePlayers==null){
			visiblePlayers = new HashSet<MotionPlayerZone>();
			visiblePlayers.add(player);
		}else if( !visiblePlayers.contains(player)){
			visiblePlayers.add(player);
		}
	}
	
	/**
	 * 移除指定用户的可视权限
	 * @param player
	 */
	public void removeVisiblePlayer(MotionPlayerZone player){
		if(visiblePlayers!=null){
			visiblePlayers.remove(player);
		}
	}
	
	/**
	 * 判断用户是否有浏览该卡的权限
	 */
	public boolean checkVisiblePlayer(MotionPlayerZone player){
		if(visiblePlayers!=null && visiblePlayers.contains(player)){
			return true;
		}else{
			return false;			
		}
	}
	
}
